feat(plugin-rsc): expose Node.js stream APIs - #1276
Open
switz wants to merge 1 commit into
Open
Conversation
… createFromNodeStream) Re-export Node.js-native stream variants from react-server-dom-webpack as new entry points (@vitejs/plugin-rsc/rsc.node, ssr.node) without duplicating existing code — each .node file re-exports from its edge counterpart and adds only the Node-specific APIs. Closes vitejs#1162 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hi-ogawa
requested changes
Aug 5, 2026
Contributor
There was a problem hiding this comment.
Thanks for PR. There has been some update on current /rsc structure https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-rsc/README.md#rsc-runtime-react-server-dom-api Can you align these node variant with new structure and API like:
/rsc.node/rsc/server.node/rsc/client.node/rsc/static.node
Having an e2e would be also desired. A dedicated starter-like example under examples/node-stream could work. I have reworked test guidance a bit recently so please take a look https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-rsc/CONTRIBUTING.md#testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Edit: Apologies, Claude went ahead and opened this PR automatically. This code was driven with Claude.
This closes my issue #1162 and addresses the feedback from the PR in #1164
Let me know if you want me to make any changes. Sorry for the quick trigger on the PR.
The flaw here is dual loading edge and node apis on the node path – if we want to refactor it, we can drop that. You'd know better than me if that's a big deal.
Closes #1162
The vendored
react-server-dom-webpackpackage includes Node.js stream APIs (renderToPipeableStream,createFromNodeStream) that are faster than their Web Streams equivalents on Node.js, but they weren't exposed by@vitejs/plugin-rsc.Approach
The
server.nodeandclient.nodevariants fromreact-server-dom-webpackare supersets of their.edgecounterparts. So each new.nodefile re-exports everything from the existing edge-based module and adds only the Node.js-specific delta — no code duplication.New entry points:
Both also re-export all existing Web Streams APIs, so consumers can switch entry points without losing access to
renderToReadableStream/createFromReadableStream.Files
New (4 files):
src/react/rsc.node.ts— low-level wrapper, re-exports./rsc+ addsrenderToPipeableStreamsrc/react/ssr.node.ts— low-level wrapper, re-exports./ssr+ addscreateFromNodeStreamsrc/rsc.node.tsx— high-level entry, re-exports./rsc+ adds wrappedrenderToPipeableStreamwith asset manifest enrichmentsrc/ssr.node.tsx— high-level entry, re-exports./ssr+ addscreateFromNodeStreamModified (2 files):
tsdown.config.ts— added 4 new entry pointssrc/types/index.ts— addedPipeableStream,RenderToPipeableStreamOptions,CreateFromNodeStreamOptionsNo changes to
package.json(wildcard export covers new paths) orplugin.ts(vendor alias already handles.nodevariants).Test plan
pnpm buildcompiles successfully with new entry pointstsc -b ./tsconfig.jsonpassescreateFromNodeStream)